Skip to content

Fix the path for tmate ssh-debug env var#282

Open
yhaliaw wants to merge 3 commits into
mainfrom
fix/tmate-env-file
Open

Fix the path for tmate ssh-debug env var#282
yhaliaw wants to merge 3 commits into
mainfrom
fix/tmate-env-file

Conversation

@yhaliaw

@yhaliaw yhaliaw commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

What this PR does

This pull request refactors how shared runner paths and the prepend_after_shebang helper are managed and used across the codebase. The main improvement is centralizing these definitions in a new runner_paths module, ensuring consistency and reducing duplication between template injection flows. Additionally, the prepend_after_shebang function is enhanced for robustness, and new tests are added to verify its behavior.

Centralization and Consistency:

  • Introduced a new runner_paths.py module to define shared constants (RUNNER_USER, RUNNER_HOME, PRE_JOB_HOOK_PATH, RUNNER_ENV_PATH) and the prepend_after_shebang function, providing a single source of truth for runner paths and injection logic.
  • Updated garm_template.py and runner_template.py to import runner paths and the injection helper from runner_paths, removing local definitions and ensuring both flows use the same logic. [1] [2]

Code Simplification and Robustness:

  • Removed the local implementation of prepend_after_shebang from garm_template.py and replaced custom script injection logic in runner_template.py with the shared helper, making code easier to maintain and less error-prone. [1] [2]
  • Improved docstrings and comments to clarify the distinction between global and per-scaleset environment variable injection. [1] [2]

Testing Enhancements:

  • Added comprehensive unit tests for prepend_after_shebang to ensure correct behavior with and without shebangs, with or without trailing newlines, and with empty snippets.

These changes improve maintainability, prevent drift between template flows, and ensure robust script injection.

Why we need it

Fix an issue where the wrong path for the .env file is used for the tmate debug-ssh env var.

Checklist

  • Changes comply with the project's coding standards and guidelines (see CONTRIBUTING.md and STYLE.md)
  • CONTRIBUTING.md has been updated upon changes to the contribution/development process (e.g. changes to the way tests are run)
  • Technical author has been assigned to review the PR in case of documentation changes (usually *.md files)
  • I updated docs/changelog.md with user-relevant changes
  • I used AI to assist with preparing this PR
  • I added or updated tests as needed (unit and integration)
  • If integration test modules are used: I updated the workflow configuration
    (e.g., in .github/workflows/integration_tests.yaml, ensure the modules list is correct)
  • If this PR involves a Grafana dashboard: I added a screenshot of the dashboard
  • If this PR involves Terraform: terraform fmt passes and tflint reports no errors
  • If this PR involves Rockcraft: I updated the version
  • If this PR adds/removes a charm, or changes a charm's base class, conventions, tooling, or repo structure: I updated the relevant AGENTS.md
  • If this PR changes .copilot-collections.yaml or .github/instructions/: I re-checked whether the AGENTS.md "12-factor divergences" guidance still matches the upstream copilot-collections guidance

@yhaliaw yhaliaw marked this pull request as ready for review July 13, 2026 08:34

@cbartz cbartz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants